home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Wexl1.cpp < prev    next >
C/C++ Source or Header  |  1999-01-23  |  2KB  |  80 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Wexl1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. //---------------------------------------------------------------------------
  10.  
  11. void ExChange (String &x, String &y)
  12. {
  13.   String z = x; x = y; y = z;
  14. }
  15.  
  16. void ExChange (double &x, double &y)
  17. {
  18.   double z = x; x = y; y = z;
  19. }
  20.  
  21. void ShowIt (String x, String y)
  22. {
  23.   Form1->Panel1->Caption = x;
  24.   Form1->Panel2->Caption = y;
  25. }
  26.  
  27. void ShowIt (double x, double y)
  28. {
  29.   Form1->Panel1->Caption = String (x);
  30.   Form1->Panel2->Caption = String (y);
  31. }
  32.  
  33. //---------------------------------------------------------------------------
  34.  
  35. String Text1, Text2;
  36. double Zahl1, Zahl2;
  37. bool Modus;
  38. TForm1 *Form1;
  39.  
  40. //---------------------------------------------------------------------------
  41. __fastcall TForm1::TForm1(TComponent* Owner)
  42.     : TForm(Owner)
  43. {
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TForm1::Button1Click(TObject *Sender)
  47. {
  48.   Text1 = InputBox
  49.     ("1. String","BestΣtigen oder NEU","Hallo");
  50.   Text2 = InputBox
  51.     ("2. String","BestΣtigen oder NEU","Hoppla");
  52.   ShowIt (Text1, Text2);
  53.   Modus = true;
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TForm1::Button2Click(TObject *Sender)
  57. {
  58.   Zahl1 = StrToFloat (InputBox
  59.     ("1. Zahl","BestΣtigen oder NEU","0"));
  60.   Zahl2 = StrToFloat (InputBox
  61.     ("2. Zahl","BestΣtigen oder NEU","1"));
  62.   ShowIt (Zahl1, Zahl2);
  63.   Modus = false;
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TForm1::Button3Click(TObject *Sender)
  67. {
  68.   if (Modus)
  69.   {
  70.     ExChange (Text1, Text2);
  71.     ShowIt (Text1, Text2);
  72.   }
  73.   else
  74.   {
  75.     ExChange (Zahl1, Zahl2);
  76.     ShowIt (Zahl1, Zahl2);
  77.   }
  78. }
  79. //---------------------------------------------------------------------------
  80.